import request from '@/utils/request'

/**
 * 录入学院和班级功能
 */

// 录入学院或班级接口
export const insertCollegeOrMajor = (importCollege) => {
  const { collegeId, college, majorId, major } = importCollege
  return request.post('/admin/college/insertCollegeOrMajor', {
    collegeId, college, majorId, major
  })
}

// 查询全部专业接口
export const getCollegeList = () => { return request.get('/admin/college') }

// 根据学院id查询班级接口
export const getMajorList = (collegeId) => { return request.get(`/admin/college/${collegeId}`) }

// 根据id查询学院或班级详细信息接口
export const getDetail = (collegeId, majorId) => {
  return request.get('/admin/college/major', {
    params: { collegeId, majorId }
  })
}

// 根据id删除学院接口
export const deleteCollege = (collegeId) => {
  return request.delete('/admin/college/deleteCollege', { params: { collegeId } })
}

// 根据id删除班级接口
export const deleteMajor = (majorId) => {
  return request.delete('/admin/college/deleteMajor', { params: { majorId } })
}

// 分页查询接口
export const getDataList = (viewCollege) => {
  const { pageNum, pageSize, collegeId, college, major, identify } = viewCollege
  return request.get('/admin/college/page', {
    params: {
      pageNum,
      pageSize,
      collegeId,
      college,
      major,
      identify
    }
  })
}

// 更新班级信息接口
export const updateMajor = (editCollege) => {
  const { majorId, major, collegeId } = editCollege
  return request.put('/admin/college/updateMajor', {
    majorId, major, collegeId
  })
}

// 更新学院信息接口
export const updateCollege = (editCollege) => {
  const { collegeId, college } = editCollege
  return request.put('/admin/college/updateCollege', {
    collegeId, college
  })
}
